import { stat } from 'fs';
import { createStore } from 'vuex';
import tagStore from './modules/tag/tag-store';

export interface State {
  userInfo: {
    id: number;
    username: string;
    nickname: string;
  };
  isCollapse: boolean
}

const store = createStore<State>({
  state() {
    return {
      userInfo: {
        id: 0,
        username: 'xjz',
        nickname: 'xjz'
      },
      isCollapse: false
    };
  },
  mutations: {
    setUserInfo(state, userInfo) {
      localStorage.set('userInfo', userInfo);
      state.userInfo = userInfo;
    },
    setIsCollapse(state, isCollapse) {
      console.log(state.isCollapse)
      state.isCollapse = isCollapse;
      console.log(state.isCollapse)
    }
  },
  modules: {
    tagStore
  }
})

export default store